package com.lanyun.auth.domain.authRole.impl;


import cn.hutool.core.util.ObjectUtil;
import com.lanyun.auth.basic.entity.AuthRole;
import com.lanyun.auth.basic.service.AuthRoleService;
import com.lanyun.auth.controller.admin.authRole.vo.AuthRoleRequestVO;
import com.lanyun.auth.convert.authRole.AuthRoleConvert;
import com.lanyun.auth.domain.authRole.AuthRoleDomainService;
import com.lanyun.web.enums.IsDeletedFlagEnum;
import com.lanyun.web.enums.IsEnabledFlagEnum;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author Jqcc
 * @Version 1.0
 * @Data 2025/3/12
 */
@Service
public class AuthRoleDomainServiceImpl implements AuthRoleDomainService {

    @Resource
    private AuthRoleService authRoleService;

    @Override
    public Boolean add(AuthRoleRequestVO authRoleRequestVO) {
        AuthRole authRole = AuthRoleConvert.INSTANCE.convert(authRoleRequestVO);
        authRole.setStatus(IsEnabledFlagEnum.ENABLED.getVal());
        return ObjectUtil.isNotNull(authRoleService.insert(authRole));
    }


    @Override
    public Boolean update(AuthRoleRequestVO authRoleRequestVO) {
        AuthRole authRole = AuthRoleConvert.INSTANCE.convert(authRoleRequestVO);
        return ObjectUtil.isNotNull(authRoleService.update(authRole));
    }

    @Override
    public Boolean delete(AuthRoleRequestVO authRoleRequestVO) {
        AuthRole authRole = AuthRoleConvert.INSTANCE.convert(authRoleRequestVO);
        authRole.setIsDeleted(IsDeletedFlagEnum.DELETED.getVal());
        return ObjectUtil.isNotNull(authRoleService.update(authRole));
    }
}
